SET.OPEN Function

Syntax

<Set> as P = SET.Open(C setname [,N file_open_mode|SQL::Arguments args [,C encryption key]])

Arguments

setname

The name of a set. The extension ".set" is assumed.

file_open_mode|SQL

Optional. Determines the access privileges that apply to the open table file. You can use one of the following system variables:

Variable
Function
FILE_RO_EXCLUSIVE

Read Only (Exclusive)

FILE_RW_EXCLUSIVE

Read or Write (Exclusive)

FILE_RO_SHARED

Read Only (Shared)

FILE_RW_SHARED

Read or Write (Shared)

encryption

Optional. Needed if the table has been encrypted, and the default encryption key has not been set (using the DEFAULT_ENCRYPTION_KEY_SET() function), of if the table was encrypted using a different encryption key than the default encryption key.

Description

Open a set - primary table of set becomes primary table of session. TIP: It is generally better to use set.open_session().

Discussion

SET.OPEN() opens a set and returns a pointer to the set. Returns the <Set> pointer variable that references the set. See TABLE.OPEN() for a description of the Open Mode and Password parameters.

If you have set a Master Password for your database, and have encrypted tables using the Tools, Security menu, then the default encryption key is automatically set when the database is opened, and you do not need to specify the Password parameter when opening tables.

Once the set has been opened, you can use the <Set> pointer variable to get pointers to the individual tables in the set. The syntax is:

<TBL> = <SET>.alias

where alias is the alias of the table in the set.

If you use the SET.OPEN() method in a script attached to a button or event on a form, it will fail because SET.OPEN() tries to make the primary table of the set the primary table of the session. This is not possible, since the table (or primary table of the set) on which the Form is based is the primary table of session, and you cannot reset the primary table of a session for a Form. For this reason, the SET.OPEN_SESSION() method is more useful, because it can be called from an event on a form.

Example

From the Interactive window:

s = set.open("invoice")
? set.current().filename_get()-> "c:\program files\a5v5\samples\alphasports\invoice.SET"
'get a pointer to the invoice_header table
t1 = s.invoice_header
'get a pointer to the customer table
t2 = s.customer
'move to the last record in the invoice set
t1.fetch_last()
'display the matching customer lastname for this invoice
? t2.lastname -> "Graham     "

See Also